home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
EnigmA Amiga Run 1996 June
/
EnigmA AMIGA RUN 08 (1996)(G.R. Edizioni)(IT)[!][issue 1996-06][EARSAN CD VII].iso
/
earcd
/
cmdity
/
yk212src.lha
/
Yak_2.12_Src
/
Prefs
/
Filereq.c
< prev
next >
Wrap
C/C++ Source or Header
|
1995-11-16
|
3KB
|
126 lines
#include <exec/types.h>
#include <exec/memory.h>
#include <intuition/intuition.h>
#include <libraries/asl.h>
#include <proto/dos.h>
#include <proto/exec.h>
#include <proto/intuition.h>
#include <proto/gadtools.h>
#include <proto/asl.h>
#include <string.h>
#ifdef MUI /* NMC */
#include <libraries/mui.h>
#include <proto/muimaster.h>
#endif /* NMC */
/* BGUI */
#ifdef BGUI /* NMC */
#include <libraries/bgui.h>
#include <libraries/bgui_macros.h>
#include <proto/bgui.h>
#endif
#include "code.h"
#include "filereq.h"
#ifdef GADTOOLS
/* Handle window IDCMP's */
STACKARGS static struct IntuiMessage *
RequesterHook(ULONG mask,
struct IntuiMessage *msg,
void *dummy)
{
if (mask == FRF_INTUIFUNC)
{
/* Only refresh events are executed */
if (msg->Class == IDCMP_REFRESHWINDOW)
{
struct Window *w=msg->IDCMPWindow;
/* Execute GadTools refresh */
GT_BeginRefresh(w);
GT_EndRefresh(w,TRUE);
}
/* Return pointer to original IntuiMessage */
return(msg);
}
return(0);
}
#endif /* GADTOOLS */
/* Open a file requester */
char *OpenFileRequester(FileReqParams *frp)
{
struct Window *win=frp->frp_Window;
struct Screen *scr=win->WScreen;
char *oldfile, *filepart;
char *dirname=NULL;
char *newfile=NULL;
ULONG len;
oldfile = frp->frp_InitialFile;
filepart = FilePart(oldfile);
len = filepart-oldfile;
if (dirname=AllocVec(len+1, MEMF_CLEAR))
{
struct FileRequester *filereq;
if (len > 0)
strncpy(dirname, oldfile, len);
dirname[len] = '\0';
*PathPart(dirname) = '\0';
/* Allocate File Requester */
if (filereq=AllocAslRequestTags(ASL_FileRequest, TAG_DONE));
{
/* Show requester */
if (AslRequestTags(filereq,
ASLFR_Window, win,
ASLFR_InitialLeftEdge, win->LeftEdge,
ASLFR_InitialTopEdge, win->TopEdge+scr->WBorTop+scr->RastPort.TxHeight+1,
ASLFR_TitleText, frp->frp_Title,
ASLFR_Flags1, FRF_INTUIFUNC | frp->frp_Flag1,
ASLFR_Flags2, FRF_REJECTICONS,
#ifdef GADTOOLS
ASLFR_HookFunc, RequesterHook,
#endif
ASLFR_InitialDrawer, dirname,
ASLFR_InitialFile, filepart,
TAG_DONE))
{
/* File name valid ? */
if (len=strlen(filereq->fr_File))
{
if (filereq->fr_Drawer)
len += strlen(filereq->fr_Drawer)+1;
if (newfile=AllocVec(len+1, MEMF_CLEAR))
{
if (filereq->fr_Drawer)
strcpy(newfile, filereq->fr_Drawer);
AddPart(newfile, filereq->fr_File, len+1);
}
}
}
FreeAslRequest(filereq);
}
FreeVec(dirname);
}
/* return new file name */
return(newfile);
}